<?php

namespace IDock\Insurance\MACN\Request;

use IDock\Http\Request;
use IDock\Http\RequestFormat;
use IDock\Http\RequestMethod;
use IDock\Http\Response;

class AllMACNRequest extends Request {

    protected $requestId;

    protected $requestType;

    protected $method = RequestMethod::POST;

    protected $format = RequestFormat::RAW;

    public function loadConfig(array $config): Request
    {
        $this->gateway = $config['gateway'] ?? '';

        $this->logsDir = $config['logsDir'] ?? '';

        $this->timeout = $config['timeout'] ?? '';

        $this->proxy = $config['proxy'];

        $this->proxyPW = $config['proxyPW'] ?? '';

        $this->proxyAccount = $config['proxyAccount'] ?? '';

        return  $this;
    }

    /**
     * @return mixed
     */
    public function getRequestType()
    {
        return $this->requestType;
    }

    /**
     * @param mixed $requestType
     */
    public function setRequestType($requestType): void
    {
        $this->requestType = $requestType;
    }

    public function responseLogs($uuid, $data)
    {
        if (!$this->logsFile) {
            return;
        }
        $data = str_replace(["\r\n","\n","\r","\t"],['','','','',''],$data);
        $repLogs = date('Y-m-d H:i:s') . " RESPONSE " . $uuid . " " . $data;
        file_put_contents($this->logsFile, $repLogs . "\r\n", FILE_APPEND);
    }


    public function payRequest(Request $request) :Response
    {
        return parent::request($request);
    }



}
